home *** CD-ROM | disk | FTP | other *** search
- Path: news1.erols.com!newsmaster@erols.com
- From: Chris Cobb <ccobb@erols.com>
- Newsgroups: comp.lang.c++
- Subject: Re: extern consts
- Date: 17 Mar 1996 14:15:14 GMT
- Organization: CSEG, Inc.
- Message-ID: <4ih6pi$tdt@news5.erols.com>
- References: <4idbcv$ue2@news7.erols.com> <4ifpmm$2mri@news-s01.ny.us.ibm.net>
- NNTP-Posting-Host: ccobb.erols.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22KIT (Windows; U; 16bit)
-
- bbogard@ibm.net wrote:
- >>The above is not possible in C nor in two of the three C++
- >>compilers I have tried it on
- >
- >Well, maybe the two other compilers you tried it on weren't ansi C++
- >compatible. Otherwise, that should work in C and C++. I don't think
- >it is a C++ only thing. All constants can be defined extern.
-
- The reason it is not possible in C is because array sizes must be
- declared with constant expressions. In C, a const variable is not
- a constant. It is just a variable whose value cannot change. But
- this is not the same thing as a constant, such as 1, 2.0, -3.
-
- In C++, const by default have static file scope. Some compilers
- apparently constrain const's to have exclusively this scope.
-
- Since this is a very short example which can be typed in in 5 minutes,
- I would ask you to try it on your compiler to see if it works. I'm
- trying to assess how widespread this support is and if it's actually
- ANSI standard C++.
-
- Chris
-
-
-
-
-
-